home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / sco / scripts / admin / maxtable < prev    next >
Encoding:
Korn shell script  |  1997-08-26  |  2.0 KB  |  70 lines

  1. #!/bin/ksh
  2. # @(#) maxtable.ksh 1.1 97/03/19
  3. # 94/02/12 john h. dubois iii
  4. # 94/06/27 Added help.
  5. # 97/03/19 Let abbreviations for file be given.  Deal with 5.0 output format.
  6.  
  7. Name=${0##*/}
  8. if [ "$1" = -h ]; then
  9.     print -u2 \
  10. "$Name: Find maximum usage of various kernel tables in sadc files.
  11. Usage: $Name sadc-logfile ...
  12. For each of the proc table, inode table, and open file table, the largest
  13. number used is printed, along with the file it was found in and the table size.
  14. Note that since sadc samples at discrete intervals, this will not neccessarily
  15. be the largest number used during the period covered by the sadc logs.
  16. If a filename does not include any '/' characters, it is searched for in the
  17. directory /usr/adm/sa.  If a number in the range 1-31 is given, the sadc
  18. logfile for that day in /usr/adm/sa is read.  If no filenames are given, all
  19. files in /usr/adm/sa are used.
  20. Example:
  21. $Name 12"
  22.     exit 0
  23. fi
  24.  
  25. if [ $# -eq 0 ]; then
  26.     cd /usr/adm/sa || exit 1
  27.     set -- sa[0-3][0-9]
  28.     if [ $# -eq 1 -a ! -f "$1" ]; then
  29.     print -ru2 -- "$Name: No sadc logfiles in /usr/adm/sa; exiting."
  30.     exit 1
  31.     fi
  32. fi
  33.  
  34. typeset -Z2 mday
  35.  
  36. for file; do
  37.     if [[ "$file" = @([0-9]) && file -ge 1 && file -le 31 ]]; then
  38.     mday=$file
  39.     file=sa$mday
  40.     fi
  41.     [[ "$file" != */* ]] && file=/usr/adm/sa/$file
  42.     sar -v -f "$file" |
  43.     sed "/^[0-9][0-9]:/!d;s'^'$file ';s'/  *'/'g" > $file.sar-v || exit
  44.     sarfiles="$sarfiles $file.sar-v"
  45. done
  46.  
  47. # sar -v output formats:
  48. # 3.2v5:
  49. # 00:00:02 proc-sz ov inod-sz ov file-sz ov lock-sz
  50. # 01:00:01  56/100  0 173/450  0 204/350  0   3/100
  51. # 3.2v4:
  52. # 00:00:01  proc-sz   ov  inod-sz   ov  file-sz   ov  lock-sz
  53. # 01:00:01  105/ 130   0  443/1075   0  424/ 682   0    6/ 128
  54.  
  55. set -A Names procs inode files
  56. set -A cols 3 5 7
  57.  
  58. typeset -i i=0
  59. while [ i -le 2 ]; do
  60.     s=${cols[i]}
  61.     set -- $(sort -nr +$(($s-1)) -$s $sarfiles | head -1)
  62.     filename=$1
  63.     echo -n "Max ${Names[i]}: $1 $2"
  64.     shift $((s-1))
  65.     echo " $1"
  66.     let i+=1
  67. done
  68.  
  69. rm -f $sarfiles
  70.